<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>修改学生</title>
    <base href="<%=request.getContextPath()+"/"%>">
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="js/jquery.js"></script>
    <script src="js/pintuer.js"></script>
    <script type="text/javascript">
        $(function () {
            $.post("/sms/offlineSchool/classServlet.do", "method=findDropDownToSelectAClass", function (res) {
                // 班级回显
                $.each(res, function (i, e) {
                    $("#sel").append("<option value='" + e.cid + "'" + (e.cid == '${requestScope.oneStudent.cid}' ? " selected='selected'" : "") + ">" + e.cname + "</option>")
                });
            }, "json")
            // 点击保存按钮
            $("#btn").click(function () {
                // 发送ajax请求
                var data = $('form').serialize() + "&method=updateOneStudent";
                $.post("/sms/offlineSchool/studentServlet.do", data, function (res) {
                    if (res == 1) {
                        alert("修改学生信息成功!")
                    } else {
                        alert("修改学生信息失败!")
                    }
                })
            })
        })
    </script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong><span class="icon-pencil-square-o"></span>修改学生</strong></div>
    <div class="body-content">
        <form method="post" class="form-x" action="">
            <input type="hidden" name="sid" value="${requestScope.oneStudent.sid}" style="width:30%"/>
            <div class="form-group">
                <div class="label">
                    <label>姓名：</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="sname" value="${requestScope.oneStudent.sname}"
                           style="width:30%"/>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>性别：</label>
                </div>
                <div class="field" style="padding-top:8px;">
                    男: <input type="radio" name="sex" value="男" ${requestScope.oneStudent.sex=='男'?'checked':''}/>
                    女: <input type="radio" name="sex" value="女" ${requestScope.oneStudent.sex=='女'?'checked':''}/>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>爱好：</label>
                </div>
                <div class="field" style="padding-top:8px;">
                    <!-- 固定的兴趣项 -->
                    <label>
                        摄影 <input type="checkbox" name="hobby" value="摄影" <c:if test="${fn:contains(requestScope.oneStudent.hobby, '摄影')}">checked</c:if>>
                    </label>
                    <label>
                        写生 <input type="checkbox" name="hobby" value="写生" <c:if test="${fn:contains(requestScope.oneStudent.hobby, '写生')}">checked</c:if>>
                    </label>
                    <label>
                        滑雪 <input type="checkbox" name="hobby" value="滑雪" <c:if test="${fn:contains(requestScope.oneStudent.hobby, '滑雪')}">checked</c:if>>
                    </label>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>出生年月：</label>
                </div>
                <div class="field">
                    <input type="date" class="input" name="birthdate" value="${requestScope.oneStudent.birthdate}"
                           style="width:30%"/>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>手机号：</label>
                </div>
                <div class="field">
                    <input type="text" class="input" name="phone" value="${requestScope.oneStudent.phone}"
                           style="width:30%"/>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>所在班级：</label>
                </div>
                <div class="field">
                    <select class="input" style="width:30%" id="sel" name="cid">
                        <option>--请选择--</option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>描述：</label>
                </div>
                <div class="field">
                    <textarea type="text" class="input" name="sdesc"
                              style="height:80px;">${requestScope.oneStudent.desc}</textarea>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <button class="button bg-main icon-check-square-o" type="button" id="btn"> 提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
</html>